package com.hnd.springframerwork.core.io;

import com.hnd.springframerwork.beans.BeansException;

import java.io.*;

/**
 * 根据文件输入流获取资源
 */
public class FileSystemResource implements Resource {
    private File file;
    private String path;

    public FileSystemResource(String path) {
        this(null, path);
    }

    public FileSystemResource(File file) {
        this(file, null);
    }

    public FileSystemResource(File file, String path) {
        this.file = file == null ? new File(path) : file;
        this.path = path == null ? file.getPath() : path;
    }

    @Override
    public InputStream getInputStream() throws IOException {
        return new FileInputStream(file);
    }
}
